package me.send.broker.mapper;

import java.util.List;
import java.util.Map;

import me.send.broker.entity.Opencity;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

public abstract interface OpencityMapper{

	/**
	 * 根据状态 查询城市名称
	 * 
	 * 编辑人：杨中仁
	 * 
	 * 编辑时间：2015年6月9日09:25:15
	 * 
	 */
	@Select(value = "select opencityid,name,openstatus,letter from opencity where openstatus = #{openstatus} ")
	public abstract List<Map<String, Object>> list_openstatus(int openstatus);

	/**
	 * 根据城市id和首字母排序查询所有城市
	 * @return
	 */
	@Select(value = "select opencityid,name,openstatus,letter  from opencity ORDER BY letter,opencityid ")
	public abstract List<Map<String, Object>> citiesAll();
	
	/**
	 * 根据字母 状态查询
	 * 
	 * 2015年6月11日11:11:16
	 */
	
	@Select(value="select opencityid,name,openstatus,letter from opencity where  letter = #{letter}")
	public abstract List<Map<String, Object>> list_opencity(Opencity opencity);
	
	/**
	 * 根据名称  获取到开放城市的详细信息
	 * 
	 * 2015-6-9 15:22:16
	 * 
	 * 杨中仁
	 */
	@Select(value="select opencityid,name,openstatus,letter from opencity where name = #{name}")
	public abstract Map<String, Object> opencity_cityname(String name);
	
	
	
	
	// 测试接口 2015年6月9日16:44:47
	@Insert(value="insert into opencity(name,createtime,updatetime,openstatus,popid) values(#{name},#{createtime},#{updatetime},#{openstatus},#{popid})")
	public abstract void opencity_save(Opencity opencity);
	
	
	@Select(value = "SELECT opencityid FROM opencity oc WHERE oc.name=#{cityname}")
	public int getCityIdByName(String cityname);
	
	
	@Select(value = "SELECT openstatus FROM opencity oc WHERE oc.name=#{cityname}")
	public int getCityIsOpenByName(String cityname);
	
}
